const {
  Sequelize,
  Model
} = require('sequelize')
const {
  sequelize
} = require('../config/db');

// 定义模型
class user extends Model {

}

user.init({
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  role:{
    type: Sequelize.STRING(16),
    allowNull: false,
    comment: '角色'
  },
  username: {
    type: Sequelize.STRING(16),
    allowNull: false,
    comment: '用户名'
  },
  account:{
    type: Sequelize.STRING(16),
    allowNull: false,
    comment: '账号'
  },
  password: {
    type: Sequelize.STRING,
    allowNull: false,
    comment: '密码'
  },
  sex: {
    type: Sequelize.STRING,
    allowNull: true,
    comment: '性别'
  },
  phone: {
    type: Sequelize.STRING,
    allowNull: true,
    comment: '联系方式'
  },
  socketID:{
    type: Sequelize.STRING,
    allowNull: true,
    comment: 'socketID'
  },
  avatar:{
    type: Sequelize.STRING,
    allowNull: true,
    comment: '头像'
  },
  hospital:{
    type: Sequelize.STRING,
    allowNull: true,
    comment: '医院'
  },
  introduction:{
    type: Sequelize.STRING,
    allowNull: true,
    comment: '个人介绍'
  },
  is_use: {
    type: Sequelize.STRING,
    allowNull: true,
    comment: '是否启用'
  },
}, {
  sequelize,
  modelName: 'user',
  tableName: 'user'
})

// user.sync({
//   force: true
// })

module.exports = user